import { groupList, groupPage, groupAdd, groupUpdate, groupDelete } from '@/api/base.group'
export default {
  namespaced: true,
  state: {},
  actions: {
    getGroupList() {
      return new Promise((resolve, reject) => {
        groupList().then(
          res => {
            resolve(res)
          }
        )
      })
    },
    //context 对象是vuex框架自己放入到第一个参数,界面上调用时传入的参数,需要放入第二个参数
    getGroupPage(context, data) {
      return new Promise((resolve, reject) => {
        groupPage(data).then(
          res => {
            resolve(res)
          }
        )
      })
    },
    addGroup(context, data) {
      return new Promise((resolve, reject) => {
        console.log(data)
        groupAdd(data).then(
          resolve()
        )
      })
    },
    updateGroup(context,data) {
      return new Promise((resolve, reject) => {
        groupUpdate(data).then(
          console.log(data),
          resolve()
        )
      })
    },
    deleteGroup(context,id) {
      return new Promise((resolve, reject) => {
        groupDelete(id).then(
          resolve()
        )
      })
    }
  }
}